package 常用类.day2.作业;

import java.util.Arrays;
import java.util.Random;

public class Test {
    public static void main1(String[] args) {
        //int []arr={1,4,2,6};
        String[]arr={"one","two","four","four"};
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));
        System.out.println("one".compareTo("four"));
    }

    public static void main(String[] args) {
        A[]arr=initArr();
        show(arr,false);
        Arrays.sort(arr);
        show(arr,true);
    }

    //对数组的初始化
    static A[] initArr(){
        Random r=new Random();
        A[]arr=new A[5];
        for(int i=1;i<=arr.length;i++){
            arr[i-1]=new A(i,r.nextInt(101));
        }
        return arr;
    }

    static void show(A[]arr,boolean sort){
        String msg=sort?"排序后":"排序前";
        System.out.println(msg);
        for(A a:arr){
            System.out.println(a);
        }
    }
}
